/**
*滚动
*/

var evm_cms_domCtrl = {
		getObj : function(){
			if(document.getElementsByTagName("marquee"))
				return document.getElementsByTagName("marquee");
			else
				return false;
		},
		marquee_replace : function(){
			var M = this.getObj();
			if(M){
					M = M[0];
				var	H = M.clientHeight,
					W = M.clientWidth,
					L = M.offsetLeft,
					T = M.offsetTop,
					C = M.style.color;
				var tarDiv = document.createElement('div');
					tarDiv.setAttribute("id","CMS_CONTENT_GRID");
					tarDiv.style.display = "absolute";
					tarDiv.style.top = T + "px";
					tarDiv.style.left = L + "px";
					tarDiv.style.height = H + "px";
					tarDiv.style.width = W + "px";
					tarDiv.style.fontSize = 26 + "px";
					tarDiv.style.color = C;
					tarDiv.style.overflow = "hidden";
					tarDiv.innerHTML = M.innerHTML;
				M.parentNode.removeChild(M);
				document.body.appendChild(tarDiv);
			}
		},
		gestrue : {
			_D : null,
			_H : 0,
			nowT : 0,
			timeOut : null,
			T : null,
			pause : false,
			timer : 61,
			init : function(T){
				clearTimeout(this.timeOut);
				if(!this.pause){
					this._D = this._getObj();
					this.rollStart(T);
					this.T = T;
				}
			},
			_getObj : function(){
				return document.getElementById("CMS_CONTENT_GRID");
			},
			rollStart : function(type){
				
				if(this._D){
					this._H = this._D.scrollHeight - this._D.offsetHeight;
					
				this.timeOut =	setTimeout(function(){
						evm_cms_domCtrl.gestrue.autoScroll(evm_cms_domCtrl.gestrue._H,evm_cms_domCtrl.gestrue. _D);
					},this.timer);
				}
			},
			autoScroll : function(H,D_){
				this.nowT = D_.scrollTop;
				if(this.T == 1){
					if(this.nowT < H){
						D_.scrollTop = D_.scrollTop + 2;
						evm_cms_domCtrl.gestrue.rollStart(this.T);
					}
				}else if(this.T == 2){
					if(this.nowT > 0){
						D_.scrollTop = D_.scrollTop - 2;
						evm_cms_domCtrl.gestrue.rollStart(this.T);
					}
				}
			},
			changeSpeed : function(V){
				switch(V){
					case 0:
						if(this.timer >= 1 && this.timer < 501)
							this.timer += 20;
						break;
					case 1:
						if(this.timer <= 501 && this.timer > 1)
							this.timer -= 20;
						break;
				}
			}
		},
		scrollController : function(evt){
			var val = evt.which || evt.keyCode;
			switch(val)
			{
				case 13:
					this.gestrue.pause = !this.gestrue.pause;
					this.gestrue.init(this.gestrue.T);
					return false;
					break;
			    case 38:
				case 306:
					this.gestrue.pause = false;
					this.gestrue.init(2);
					return false;
					break;
				case 40:
				case 307:
					this.gestrue.pause = false;
					this.gestrue.init(1);
					return false;
					break;
				case 37:
					this.gestrue.changeSpeed(1);
					return false;
					break;
				case 39:
					this.gestrue.changeSpeed(0);
					return false;
					break;
			}
		},
		trackKey : function(event){
			return evm_cms_domCtrl.scrollController(event);
		}
};
